package com.bishe.demo.modules.hotel.hotelRoom.controller;

import com.bishe.demo.modules.common.entity.ResultEntity;
import com.bishe.demo.modules.hotel.hotelRoom.entity.Room;
import com.bishe.demo.modules.hotel.hotelRoom.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class RoomController {
    @Autowired
    private RoomService roomService;

    @PostMapping(value = "/room", consumes = "application/json")
    public ResultEntity<Room> insertRoom(@RequestBody Room room) {
        return roomService.insertRoom(room);
    }

    @GetMapping(value = "/rooms/{hotelId}")
    public List<Room> getRoomsByHotelId(@PathVariable int hotelId) {
        return roomService.getRoomsByHotelId(hotelId);
    }

    @PutMapping(value = "/hotelRooms", consumes = "application/json")
    public ResultEntity<List<Room>> updateRoom(@RequestBody List<Room> rooms) {
        return roomService.updateRoom(rooms);
    }
}
